﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CreateContinuousMFGFromCurve.CApCMCCreateContinuousMFGFromCurveEmsLogic
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.DataTypes;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.CreateContinuousMFGFromCurve;

internal class CApCMCCreateContinuousMFGFromCurveEmsLogic : CApCMCCreateContinuousMFGFromCurveLogic
{
  private TextBox _3DFolder;
  private Button _browseButton;
  private const string _CONTINUOUS_MFG_METADATA_TYPE_EMS = "PmContinuousMfg";
  private const string _3D_FOLDER_LOCATION_REGISTRY = "3DFolderLocation";

  public CApCMCCreateContinuousMFGFromCurveEmsLogic(
    TxObjGridCtrl mfgList,
    TxObjEditBoxCtrl assignToPart,
    ComboBox mfgType,
    TextBox folder,
    Button browseButton,
    Button okButton)
    : base(mfgList, assignToPart, mfgType, okButton, "PmContinuousMfg")
  {
    this._3DFolder = folder;
    this._browseButton = browseButton;
  }

  public override List<TxSeamMfgFeature> CreateMFGs(string mfgTypeName)
  {
    this.CallCreateSeamMfg = (Func<ITxObject, ITxSeamMfgFeatureCreationData, TxSeamMfgFeature>) ((curveObj, data) => TxApplication.ActiveDocument.MfgRoot.CreateSeamMfgFeature(curveObj, data, this._3DFolder.Text));
    return base.CreateMFGs(mfgTypeName);
  }

  public void AddCurvesToList(TxObjectList items)
  {
    foreach (ITxObject itxObject in (Collection<ITxObject>) items)
      this._mfgList.AppendObject(itxObject);
  }

  public void EnableOrDisableButtons()
  {
    bool flag = this._mfgList.Count > 0 && !string.IsNullOrEmpty(this._3DFolder.Text) && (this._assignToPart.Object != null || !(((Control) this._assignToPart).Text != string.Empty));
    if (flag)
    {
      try
      {
        for (int index = 0; index < this._mfgList.Count & flag; ++index)
        {
          if (string.IsNullOrEmpty(this._mfgList.GetTextValue(index, 0)))
            flag = false;
        }
      }
      catch
      {
        flag = false;
      }
    }
    this._okButton.Enabled = flag;
  }
}
